/*
 * @Author: 于建霞
 * @Date: 2021-06-17 20:08:33
 * @LastEditTime: 2021-06-23 21:16:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \base-framework-web\src\services\sysSetting.ts
 */
import { RequestApi } from '@/net/common/API';
import Const from '@/utils/Const';

// 菜单管理-保存菜单
export function saveMenu(params: any) {
  let data = Const.dealParamsSwitch(params);
  const apiObj = {
    url: '/bf/sys/res/save',
    method: 'post',
    data,
  };
  return new RequestApi().getRequest(apiObj);
}
// 获取表格数据
export function getTreeData(params: any) {
  let data = Const.dealParamsSwitch(params);
  const apiObj = {
    url: '/bf/sys/res/tree',
    method: 'post',
    data,
  };
  return new RequestApi().getRequest(apiObj);
}
// 获取所有可用的子系统类型资源，用于菜单查询
export function getSubsystem(params: any) {
  let data = Const.dealParamsSwitch(params);
  const apiObj = {
    url: '/bf/sys/res/get/subsystem',
    method: 'get',
  };
  return new RequestApi().getRequest(apiObj);
}
// 检查选中的资源中是否已存在授权，true为已存在，false为不存在，用于资源编辑、停用、删除时做校验
export function authorization_check(params: any) {
  let data = Const.dealParamsSwitch(params);
  const apiObj = {
    url: '/bf/sys/res/authorization_check',
    method: 'post',
    data,
  };
  return new RequestApi().getRequest(apiObj);
}
// 状态修改
export function modifyStatus(params: any) {
  let data = Const.dealParamsSwitch(params);
  const apiObj = {
    url: '/bf/sys/res/status',
    method: 'post',
    data,
  };
  return new RequestApi().getRequest(apiObj);
}
// 批量删除系统功能资源
export function deleteByIds(params: any) {
  let data = Const.dealParamsSwitch(params);
  const apiObj = {
    url: '/bf/sys/res/delete',
    method: 'post',
    data,
  };
  return new RequestApi().getRequest(apiObj);
}
// 通过ID查询系统功能资源详情
export function getItemById(params: any) {
  let data = Const.dealParamsSwitch(params);
  const apiObj = {
    url: `/bf/sys/res/get/${params}`,
    method: 'get',
  };
  return new RequestApi().getRequest(apiObj);
}
// 批量删除系统功能资源
export function update(params: any) {
  let data = Const.dealParamsSwitch(params);
  const apiObj = {
    url: '/bf/sys/res/update',
    method: 'post',
    data,
  };
  return new RequestApi().getRequest(apiObj);
}